package com.jsgt.greekfire.dao.model

import android.os.Parcel
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import org.jetbrains.annotations.NotNull

@Entity(tableName = "address")
class ContactAddress() : Parcelable {

    @PrimaryKey(autoGenerate = true)
    var id: Int = 0 //主键递增id

    @ColumnInfo
    @NotNull
    var name: String? = null  //名称

    @ColumnInfo
    @NotNull
    var address: String? = null  //地址

    @ColumnInfo
    @NotNull
    var key: String? = null //币种

    @ColumnInfo
    var description: String? = null //描述

    constructor(parcel: Parcel) : this() {
        id = parcel.readInt()
        name = parcel.readString()
        address = parcel.readString()
        key = parcel.readString()
        description = parcel.readString()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeInt(id)
        parcel.writeString(name)
        parcel.writeString(address)
        parcel.writeString(key)
        parcel.writeString(description)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<ContactAddress> {
        override fun createFromParcel(parcel: Parcel): ContactAddress {
            return ContactAddress(parcel)
        }

        override fun newArray(size: Int): Array<ContactAddress?> {
            return arrayOfNulls(size)
        }
    }
}